package com.wasion.core.util;

/**
 * 
 * @ClassName: FrameFormatter
 * @Description: 帧结构格式化
 * @author 高意
 * @date 2014-9-11 下午2:04:15
 * 
 */
public class FrameFormatter {

	/**
	 * 
	 * @Title: format
	 * @Description: 以空格格式化报文
	 * @param
	 * @return
	 * @throws
	 */
	public static String format(String frame) {

		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < frame.length();) {
			sb = sb.append(frame.substring(i, i + 2) + " ");
			i += 2;
		}
		return sb.toString();
	}

	/**
	 * 
	 * @Title: deformat
	 * @Description: 反格式化，去除多余的空格
	 * @param
	 * @return
	 * @throws
	 */
	public static String deformat(String frame) {

		return frame.replaceAll(" ", "");
	}
}
